package com.foreknow.demo7;

import java.sql.Wrapper;
import java.util.Scanner;

/**
 * 封装类(包装类)：主要的作用是用作类型的转换
 * 每一种基本数据类型都会对应一个包装类
 *  byte---------Byte
 *  short--------Short
 *  int----------Integer
 *  long---------Long
 *  float--------Float
 *  double-------Double
 *  char---------Character
 *  boolean------Boolean
 *
 *  面试题 ： int与Integer有什么区别？
 */
public class WarpDemo {

    public void m1(Integer i){
        int x = i;
        System.out.println(x);
    }

    public String m2() {
        return "3.14";
    }

        public static void main(String[] args) {
            WarpDemo warpDemo = new WarpDemo();
            warpDemo.m1(3);
            String s = warpDemo.m2();
            s.length();
            double d = warpDemo.m2().length();
            System.out.println(d);



        Integer i1 = new Integer(20);
        Integer i2 = new Integer(20);
        System.out.println(i1==i2);
        System.out.println(i1.equals(i2));

        System.out.println("---------------------------------");

//        Scanner input = new Scanner(System.in);
//        System.out.println("请输入一个数A");
//        String num_a = input.next();
//        System.out.println("请输入一个数B");
//        String num_b = input.next();
//
//        int aa = Integer.parseInt(num_a);
//        double a = Double.parseDouble(num_a);
//        double b = Double.parseDouble(num_b);
//        System.out.println(a+b);

        System.out.println("---------------------------------");
        int i = 34;
        Integer integer = new Integer(i);
        //jdk5之后可以
        Integer integer1 = 34; //自动装箱
        System.out.println(integer1);

        System.out.println("---------------------------------");
        Integer integer2 = 56;
        int x = integer2; //自动拆箱
        System.out.println(x);

    }
}
